import React from 'react';
import { Button } from 'antd';
import emitter from '../../util/events';

import './style.css'

export default class SubmitButton extends React.Component {
    constructor(props) {
        super(props);
        this.state = {};
        this.handleClick = this.handleClick.bind(this);
    }

    handleClick() {
        emitter.emit('setFormData');
        emitter.emit('getFormData');
    };

    componentDidMount() {
        // data事件通讯
        this.eventEmitter = emitter.addListener('submitForm', (data) => {
            console.log('emitterChangeData', data)
        });
    }

    // componentWillUnmount() {
    //     emitter.removeListener(this.eventEmitter);
    // }

    render() {
        return (
            <div className="submitButton">
                <Button type="primary" icon="save" onClick={this.handleClick}>保存</Button>
                <Button>取消</Button>
            </div>
        )
    }
}